<template>
  <div @click="onToggle">
    <svg-icon
      id="guide-full"
      :icon="isFullscreen ? 'exit-fullscreen' : 'fullscreen'"
    />
  </div>
</template>

<script setup>
import { ref, onMounted, onUnmounted } from 'vue';
import screenfull from 'screenfull';

const isFullscreen = ref(false);

const onToggle = () => {
  screenfull.toggle();
};

const handleFullScreenChange = () => {
  isFullscreen.value = screenfull.isFullscreen;
};

onMounted(() => {
  screenfull.on('change', handleFullScreenChange);
});
onUnmounted(() => {
  screenfull.off('change', handleFullScreenChange);
});
</script>

<style lang='scss' scoped></style>
